﻿using System;
using System.Runtime.InteropServices;

namespace RayDen.Library.Core.Primitives
{
    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public struct Float4
    {
        public float x, y, z, w;


        public float this[int index]
        {
            get
            {
                switch (index)
                {
                    case 0:
                        return this.x;
                    case 1:
                        return y;
                    case 2:
                        return z;
                    case 3:
                        return this.w;
                    default:
                        throw new ArgumentException("index");
                }
            }

            set
            {
                switch (index)
                {
                    case 0:
                        this.x = value;
                        break;
                    case 1:
                        y = value;
                        break;
                    case 2:
                        z = value;
                        break;
                    case 3:
                        this.w = value;
                        break;
                    default:
                        throw new ArgumentException("index");
                }
            }

        }

        public Float4(float c)
        {
            y = z = this.w = this.x = c;
        }

        public Float4(float a0, float a1, float a2, float a3)
        {
            this.x = a0;
            y = a1;
            z = a2;
            this.w = a3;
        }
        public Float4( double a0, double a1, double a2, double a3 )
        {
            this.x = (float)a0;
            y = (float)a1;
            z = (float)a2;
            this.w = (float)a3;
        }
        public Float4( ref Float4 a)
        {
            this.x = a.x;
            y = a.y;
            z = a.z;
            this.w = a.w;
        }
    }

}
